home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 001 / pibt3sp4.arc / SETINPTK.PAS < prev    next >
Pascal/Delphi Source File  |  1985-09-06  |  26KB  |  678 lines

  1. (*----------------------------------------------------------------------*)
  2. (*                Set_Input_Keys --- Set Input Key Values               *)
  3. (*----------------------------------------------------------------------*)
  4.  
  5. OVERLAY PROCEDURE Set_Input_Keys( File_Name : AnyStr );
  6.  
  7. (*----------------------------------------------------------------------*)
  8. (*                                                                      *)
  9. (*     Procedure:  Set_Input_Keys                                       *)
  10. (*                                                                      *)
  11. (*     Purpose:    Set values of function keys and keypad keys          *)
  12. (*                                                                      *)
  13. (*     Calling Sequence:                                                *)
  14. (*                                                                      *)
  15. (*        Set_Input_Keys( File_Name : AnyStr );                         *)
  16. (*                                                                      *)
  17. (*           If not null is file name to read key definitions from.     *)
  18. (*                                                                      *)
  19. (*     Calls:                                                           *)
  20. (*               Menu_Display_Choices                                   *)
  21. (*               Menu_Get_Choices                                       *)
  22. (*               Read_Key_Defs_From_File;                               *)
  23. (*               Get_Key_Defs_From_Keyboard;                            *)
  24. (*               Write_Key_Defs_To_File;                                *)
  25. (*                                                                      *)
  26. (*     Remarks:                                                         *)
  27. (*                                                                      *)
  28. (*        This whole section of code should be reworked to use          *)
  29. (*        full-screen editing at some point.                            *)
  30. (*                                                                      *)
  31. (*----------------------------------------------------------------------*)
  32.  
  33. VAR
  34.    Input_Key_File      : TEXT;
  35.    Input_Key_File_Name : AnyStr;
  36.    Key_Name            : STRING[3];
  37.    Key_Text            : AnyStr;
  38.    Section_No          : INTEGER;
  39.    Key_Def_Text        : AnyStr;
  40.    Key_Number          : INTEGER;
  41.    L_Text              : INTEGER;
  42.    I                   : INTEGER;
  43.    J                   : INTEGER;
  44.    Input_Key_Menu      : Menu_Type;
  45.    Done                : BOOLEAN;
  46.    Key_Type            : INTEGER;
  47.  
  48. (*----------------------------------------------------------------------*)
  49. (*  Process_Function_Key_Definition --- Process Function Key Definition *)
  50. (*----------------------------------------------------------------------*)
  51.  
  52. PROCEDURE Process_Key_Definition;
  53.  
  54. (*----------------------------------------------------------------------*)
  55. (*                                                                      *)
  56. (*     Procedure:  Process_Key_Definition                               *)
  57. (*                                                                      *)
  58. (*     Purpose:    Process and store key definition string              *)
  59. (*                                                                      *)
  60. (*     Calling Sequence:                                                *)
  61. (*                                                                      *)
  62. (*        Process_Key_Definition;                                       *)
  63. (*                                                                      *)
  64. (*           On entry, Key_Text should have the key definition text     *)
  65. (*           as read from a file.                                       *)
  66. (*                                                                      *)
  67. (*----------------------------------------------------------------------*)
  68.  
  69. (* STRUCTURED *) CONST
  70.    Keypad_Nos:  ARRAY[0..10] OF BYTE
  71.                 = ( 9, 7, 4, 8, 2, 0, 3, 5, 1, 6, 10 );
  72.  
  73. BEGIN (* Process_Key_Definition *)
  74.  
  75.    L_Text         := LENGTH( Key_Text );
  76.  
  77.                                    (* Get key name   *)
  78.  
  79.    Key_Name       := COPY( Key_Text, 1, 2 );
  80.    IF Key_Text[3] <> '=' THEN
  81.       Key_Name := Key_Name + Key_Text[3];
  82.  
  83.                                    (* Choose section *)
  84.    CASE UpCase( Key_Name[1] ) OF
  85.  
  86.       'F': Section_No := 1;
  87.  
  88.       'S': Section_No := 2;
  89.  
  90.       'C': IF UpCase( Key_Name[2] ) = 'K' THEN
  91.               Section_No := 7
  92.            ELSE
  93.               Section_No := 3;
  94.  
  95.       'A': IF UpCase( Key_Name[2] ) = 'K' THEN
  96.               Section_No := 6
  97.            ELSE
  98.               Section_No := 4;
  99.  
  100.       'K': Section_No := 5;
  101.  
  102.       ELSE
  103.            Section_No := 0;
  104.  
  105.    END (* Case *);
  106.                                    (* Key text initially null *)
  107.    Key_Def_Text   := '';
  108.                                    (* Get key number *)
  109.    I              := 2;
  110.    Key_Number     := 0;
  111.  
  112.    WHILE ( I <= L_Text ) AND ( Key_Text[I] <> '=' ) DO
  113.       BEGIN
  114.  
  115.          CASE Key_Text[I] OF
  116.             '0'..'9': Key_Number := Key_Number * 10 + ORD(Key_Text[I]) - ORD('0');
  117.             '.'     : Key_Number := 10;
  118.          END (* Case *);
  119.  
  120.          I          := I + 1;
  121.  
  122.       END;
  123.                                    (* Skip past '=' sign *)
  124.  
  125.    IF Key_Text[I] = '=' THEN I := I + 1;
  126.  
  127.                                    (* Get key text *)
  128.    IF ( L_Text - I + 1 ) > 0 THEN
  129.       Key_Def_Text   := Read_Ctrls( COPY( Key_Text, I, L_Text - I + 1 ) );
  130.  
  131.                                    (* Insert key text in function key *)
  132.                                    (* or keypad key.                  *)
  133.    IF Section_No IN [1..4] THEN
  134.       BEGIN
  135.          IF ( Key_Number > 0 ) AND ( Key_Number < 11 ) THEN
  136.               Function_Keys[ Section_No , Key_Number ] := Key_Def_Text;
  137.       END
  138.    ELSE IF Section_No IN [5..7] THEN
  139.       BEGIN
  140.          IF ( Key_Number >= 0 ) AND ( Key_Number < 11 ) THEN
  141.               Keypad_Keys[ Section_No - 4 , Keypad_Nos[ Key_Number ] ]
  142.                  := Key_Def_Text;
  143.       END;
  144.  
  145. END   (* Process_Key_Definition *);
  146.  
  147. (*----------------------------------------------------------------------*)
  148. (*      Read_Key_Defs_From_File --- get key definitions from file       *)
  149. (*----------------------------------------------------------------------*)
  150.  
  151. PROCEDURE Read_Key_Defs_From_File;
  152.  
  153. (*----------------------------------------------------------------------*)
  154. (*                                                                      *)
  155. (*     Procedure:  Read_Key_Defs_From_File                              *)
  156. (*                                                                      *)
  157. (*     Purpose:    Reads function key and keypad key values from file   *)
  158. (*                                                                      *)
  159. (*     Calling Sequence:                                                *)
  160. (*                                                                      *)
  161. (*        Read_Key_Defs_From_File;                                      *)
  162. (*                                                                      *)
  163. (*----------------------------------------------------------------------*)
  164.  
  165. BEGIN (* Read_Key_Defs_From_File *)
  166.  
  167.                                    (* Announce input key definition *)
  168.    Save_Screen( Saved_Screen );
  169.    Draw_Menu_Frame( 10, 10, 65, 15, Menu_Frame_Color,
  170.                     Menu_Text_Color, 'Read Input Key Definitions' );
  171.  
  172.                                    (* Prompt for file with definitions *)
  173.                                    (* if not already specified         *)
  174.  
  175.    Input_Key_File_Name := File_Name;
  176.  
  177.    WRITELN;
  178.    WRITE('File with definitions? ');
  179.  
  180.    IF LENGTH( Input_Key_File_Name ) <= 0 THEN
  181.       READLN( Input_Key_File_Name )
  182.    ELSE
  183.       BEGIN
  184.          WRITE( Input_Key_File_Name );
  185.          DELAY( One_Second_Delay );
  186.       END;
  187.  
  188.                                    (* Assume .FNC if type not given *)
  189.  
  190.    IF ( POS( '.', Input_Key_File_Name ) = 0 ) THEN
  191.       Input_Key_File_Name := Input_Key_File_Name + '.FNC';
  192.  
  193.                                    (* Attach file with definitions *)
  194.  
  195.    ASSIGN( Input_Key_File , Input_Key_File_Name );
  196.        (*$I-*)
  197.    RESET ( Input_Key_File );
  198.        (*$I+*)
  199.                                    (* See if openable *)
  200.    IF IoResult <> 0 THEN
  201.       BEGIN (* File bad *)
  202.          WRITELN;
  203.          WRITELN('*** File ',Input_Key_File_Name,' can''t be found.');
  204.          DELAY( Two_Second_Delay );
  205.       END   (* File bad *)
  206.    ELSE
  207.       BEGIN (* File OK, read definitions *)
  208.  
  209.          REPEAT
  210.  
  211.             Key_Text       := ' ';
  212.                                    (* Read key definition *)
  213.  
  214.             READLN( Input_Key_File , Key_Text );
  215.  
  216.                                    (* Process it *)
  217.  
  218.             Process_Key_Definition;
  219.  
  220.          UNTIL( EOF( Input_Key_File ) );
  221.  
  222.                                    (* Indicate definitions finished *)
  223.  
  224.          WRITELN('Function key definitions loaded.');
  225.  
  226.          DELAY( Two_Second_Delay );
  227.  
  228.          CLOSE( Input_Key_File );
  229.  
  230.       END   (* File OK, read definitions *);
  231.  
  232.                                    (* Restore previous screen          *)
  233.    Restore_Screen( Saved_Screen );
  234.  
  235.    Reset_Global_Colors;
  236.  
  237. END   (* Read_Key_Defs_From_File *);
  238.  
  239. (*----------------------------------------------------------------------*)
  240. (*       Get_Key_Defs_From_Keyboard --- get key defs. from keyboard     *)
  241. (*----------------------------------------------------------------------*)
  242.  
  243. PROCEDURE Get_Key_Defs_From_Keyboard;
  244.  
  245. (*----------------------------------------------------------------------*)
  246. (*                                                                      *)
  247. (*     Procedure:  Get_Key_Defs_From_Keyboard                           *)
  248. (*                                                                      *)
  249. (*     Purpose:    Read function and keypad key values from keyboard    *)
  250. (*                                                                      *)
  251. (*     Calling Sequence:                                                *)
  252. (*                                                                      *)
  253. (*        Get_Key_Defs_From_Keyboard;                                   *)
  254. (*                                                                      *)
  255. (*----------------------------------------------------------------------*)
  256.  
  257. VAR
  258.    Local_Save : Saved_Screen_Ptr;
  259.    Page_No    : INTEGER;
  260.    Key_Menu   : Menu_Type;
  261.    Key_Type   : INTEGER;
  262.    Defs_Done  : BOOLEAN;
  263.  
  264. (*----------------------------------------------------------------------*)
  265. (*       Display_Key_Defs --- Display current key definitions           *)
  266. (*----------------------------------------------------------------------*)
  267.  
  268. PROCEDURE Display_Key_Defs( Key_Type : INTEGER );
  269.  
  270. (*----------------------------------------------------------------------*)
  271. (*                                                                      *)
  272. (*     Procedure:  Display_Key_Defs                                     *)
  273. (*                                                                      *)
  274. (*     Purpose:    Display portion of current key definitions           *)
  275. (*                                                                      *)
  276. (*     Calling Sequence:                                                *)
  277. (*                                                                      *)
  278. (*        Display_Key_Defs( Key_Type: INTEGER );                        *)
  279. (*                                                                      *)
  280. (*           Key_Type --- Key type to display.                          *)
  281. (*                        = 1:  F1 through F10                          *)
  282. (*                        = 2:  Shift F1 through Shift F10              *)
  283. (*                        = 3:  Ctrl F1 through Ctrl F10                *)
  284. (*                        = 4:  Alt F1 through Alt F10                  *)
  285. (*                        = 5:  Keypad keys                             *)
  286. (*                        = 6:  Alt keypad keys                         *)
  287. (*                        = 7:  Ctrl keypad keys                        *)
  288. (*                                                                      *)
  289. (*----------------------------------------------------------------------*)
  290.  
  291. (* STRUCTURED *) CONST
  292.    Long_Key_Names : ARRAY[1..10] OF STRING[7] =
  293.                     ( 'Up', 'Left', 'Right', 'Down',
  294.                       'Home', 'PgUp', 'End', 'PgDn', 'Ins', 'Del' );
  295.  
  296. VAR
  297.    I          : INTEGER;
  298.    J          : INTEGER;
  299.    Key_Prefix : STRING[10];
  300.    Defs_Done  : BOOLEAN;
  301.  
  302. BEGIN (* Display_Key_Defs *)
  303.  
  304.    GoToXY( 1 , 1 );
  305.                                    (* Display title                *)
  306.  
  307.    WRITELN(' # -Key Name- ',
  308.            '------------------------Definition-------------------------- ');
  309.    WRITELN(' ');
  310.  
  311.    CASE Key_Type OF
  312.  
  313.       1:  Key_Prefix := 'F';
  314.       2:  Key_Prefix := 'Shift F';
  315.       3:  Key_Prefix := 'Ctrl F';
  316.       4:  Key_Prefix := 'Alt F';
  317.       5:  Key_Prefix := '';
  318.       6:  Key_Prefix := 'Alt ';
  319.       7:  Key_Prefix := 'Ctrl ';
  320.       ELSE;
  321.  
  322.    END (* Case *);
  323.  
  324.    IF Key_Type IN [1..4] THEN
  325.       FOR I := 1 TO 10 DO
  326.          BEGIN
  327.             GoToXY( 1 , I + 3 );
  328.             ClrEol;
  329.             WRITE( I:2,' ',Key_Prefix , I );
  330.             GoToXY( 15 , I + 3 );
  331.             WRITE( Function_Keys[ Key_Type , I ] );
  332.          END
  333.    ELSE
  334.       FOR I := 1 TO 10 DO
  335.          BEGIN
  336.             GoToXY( 1 , I + 3 );
  337.             ClrEol;
  338.             WRITE( I:2,' ',Key_Prefix , Long_Key_Names[I] );
  339.             GoToXY( 15 , I + 3 );
  340.             WRITE( Keypad_Keys[ Key_Type - 4 , I ] );
  341.          END;
  342.  
  343.    FOR I := 14 TO 19 DO
  344.       BEGIN
  345.          GoToXY( 1 , I );
  346.          ClrEol;
  347.       END;
  348.  
  349. END   (* Display_Key_Defs *);
  350.  
  351. (*----------------------------------------------------------------------*)
  352. (*              Update_Key_Defs --- Update key definitions              *)
  353. (*----------------------------------------------------------------------*)
  354.  
  355. PROCEDURE Update_Key_Defs( Key_Type: INTEGER; VAR Defs_Done : BOOLEAN );
  356.  
  357. (*----------------------------------------------------------------------*)
  358. (*                                                                      *)
  359. (*     Procedure:  Update_Key_Defs                                      *)
  360. (*                                                                      *)
  361. (*     Purpose:    Update key definitions                               *)
  362. (*                                                                      *)
  363. (*     Calling Sequence:                                                *)
  364. (*                                                                      *)
  365. (*        Update_Key_Defs( Key_Type: INTEGER; VAR Defs_Done: BOOLEAN ); *)
  366. (*                                                                      *)
  367. (*           Key_Type --- Key type to define.                           *)
  368. (*                        = 1:  F1 through F10                          *)
  369. (*                        = 2:  Shift F1 through Shift F10              *)
  370. (*                        = 3:  Ctrl F1 through Ctrl F10                *)
  371. (*                        = 4:  Alt F1 through Alt F10                  *)
  372. (*                        = 5:  Keypad keys                             *)
  373. (*                        = 6:  Alt keypad keys                         *)
  374. (*                        = 7:  Ctrl keypad keys                        *)
  375. (*                                                                      *)
  376. (*           Defs_Done --- TRUE if definitions complete.                *)
  377. (*                                                                      *)
  378. (*----------------------------------------------------------------------*)
  379.  
  380. VAR
  381.    Key_No     : INTEGER;
  382.    Key_No_Str : STRING[10];
  383.    OK_Number  : BOOLEAN;
  384.    I          : INTEGER;
  385.  
  386. BEGIN (* Update_Key_Defs *)
  387.                                    (* Not through with definitions yet *)
  388.    Defs_Done := FALSE;
  389.                                    (* Get number of key to change *)
  390.    REPEAT
  391.                                    (* Assume good key number found     *)
  392.       OK_Number := TRUE;
  393.                                    (* Clear any previous error         *)
  394.       GoToXY( 1 , 17 );
  395.       ClrEol;
  396.  
  397.       GoToXY( 1 , 16 );
  398.  
  399.       WRITE(' Enter key number to redefine or <CR> to quit: ');
  400.       ClrEol;
  401.  
  402.       READLN( Key_No_Str );
  403.  
  404.       Defs_Done := ( LENGTH( Key_No_Str ) = 0 );
  405.  
  406.       Key_No := 0;
  407.  
  408.       IF ( NOT Defs_Done ) THEN
  409.          BEGIN
  410.             FOR I := 1 TO LENGTH( Key_No_Str ) DO
  411.                IF Key_No_Str[I] IN ['0'..'9'] THEN
  412.                   Key_No := Key_No * 10 + ORD(Key_No_Str[I]) - ORD('0')
  413.                ELSE
  414.                   OK_Number := FALSE;
  415.             OK_Number := OK_Number AND ( Key_No > 0 ) AND ( Key_No < 11 );
  416.          END;
  417.  
  418.       IF ( NOT OK_Number ) THEN
  419.          BEGIN
  420.             GoToXY( 1 , 17 );
  421.             WRITE(' *** Bad key number, try again.');
  422.             ClrEol;
  423.             DELAY( 1000 );
  424.          END;
  425.  
  426.    UNTIL ( OK_Number OR Defs_Done );
  427.  
  428.                                    (* If no number entered, quit; *)
  429.                                    (* else, pick up definition.   *)
  430.    IF ( NOT Defs_Done ) THEN
  431.       BEGIN
  432.          GoToXY( 1 , 17 );
  433.          WRITELN(' Enter new key definition ...');
  434.          WRITE(' -->');
  435.          ClrEol;
  436.          READLN( Key_Text );
  437.                                     (* Store new key definition *)
  438.  
  439.          IF Key_Type IN [1..4] THEN
  440.             Function_Keys[Key_Type,Key_No] := Read_Ctrls( Key_Text )
  441.          ELSE
  442.             Keypad_Keys[Key_Type - 4, Key_No] := Read_Ctrls( Key_Text );
  443.  
  444.       END;
  445.  
  446. END   (* Update_Key_Defs *);
  447.  
  448. (*----------------------------------------------------------------------*)
  449.  
  450. BEGIN (* Get_Key_Defs_From_Keyboard *)
  451.  
  452.                                    (* Save screen *)
  453.    Save_Screen( Local_Save );
  454.                                    (* Get back whole screen as window *)
  455.                                    (* for key display                 *)
  456.    Window( 1, 1, 80, 25 );
  457.  
  458.    ClrScr;
  459.  
  460.    Draw_Menu_Frame( 1, 2, 80, 23, Menu_Frame_Color,
  461.                     Menu_Text_Color, 'Input key definition' );
  462.  
  463.    Window( 2, 3, 78, 22 );
  464.                                    (* Set up menu *)
  465.    Key_Menu.Menu_Size    := 8;
  466.    Key_Menu.Menu_Row     := 11;
  467.    Key_Menu.Menu_Column  := 15;
  468.    Key_Menu.Menu_Tcolor  := Menu_Text_Color;
  469.    Key_Menu.Menu_Bcolor  := BackGround_Color;
  470.    Key_Menu.Menu_Fcolor  := Menu_Frame_Color;
  471.    Key_Menu.Menu_Width   := 0;
  472.    Key_Menu.Menu_Height  := 0;
  473.    Key_Menu.Menu_Default := 1;
  474.  
  475.    FOR I := 1 TO 8 DO
  476.       WITH Key_Menu.Menu_Entries[I] DO
  477.       BEGIN
  478.          Menu_Item_Row    := I;
  479.          Menu_Item_Column := 2;
  480.          CASE I Of
  481.             1:  Menu_Item_Text:= '1) Function keys 1 to 10';
  482.             2:  Menu_Item_Text:= '2) Shifted function keys';
  483.             3:  Menu_Item_Text:= '3) Ctrl + function keys';
  484.             4:  Menu_Item_Text:= '4) Alt + function keys';
  485.             5:  Menu_Item_Text:= '5) Keypad keys';
  486.             6:  Menu_Item_Text:= '6) Alt + keypad keys';
  487.             7:  Menu_Item_Text:= '7) Ctrl + keypad keys';
  488.             8:  Menu_Item_Text:= '8) Quit';
  489.          END (* CASE *);
  490.       END;
  491.  
  492.    Key_Menu.Menu_Title := 'Select keys to define:';
  493.  
  494.                                    (* Loop until quit chosen *)
  495.    Done := FALSE;
  496.  
  497.    REPEAT
  498.                                    (* Display menu of choices *)
  499.  
  500.       Menu_Display_Choices( Key_Menu );
  501.       Key_Type := Menu_Get_Choice( Key_Menu , Erase_Menu );
  502.  
  503.                                    (* Do requested operation *)
  504.       IF Key_Type <> 8 THEN
  505.          REPEAT
  506.             Display_Key_Defs( Key_Type );
  507.             Update_Key_Defs( Key_Type , Defs_Done );
  508.          UNTIL( Defs_Done )
  509.       ELSE
  510.          Done := TRUE;
  511.  
  512.    UNTIL Done;
  513.                                    (* Restore previous screen          *)
  514.    Restore_Screen( Local_Save );
  515.  
  516.    Reset_Global_Colors;
  517.  
  518. END   (* Get_Key_Defs_From_Keyboard *);
  519.  
  520. (*----------------------------------------------------------------------*)
  521. (*  Write_Key_Defs_To_File --- write revised key definitions to file    *)
  522. (*----------------------------------------------------------------------*)
  523.  
  524. PROCEDURE Write_Key_Defs_To_File;
  525.  
  526. (*----------------------------------------------------------------------*)
  527. (*                                                                      *)
  528. (*     Procedure:  Write_Key_Defs_To_File                               *)
  529. (*                                                                      *)
  530. (*     Purpose:    Write updated function key and keypad key values     *)
  531. (*                                                                      *)
  532. (*     Calling Sequence:                                                *)
  533. (*                                                                      *)
  534. (*        Write_Key_Defs_To_File;                                       *)
  535. (*                                                                      *)
  536. (*----------------------------------------------------------------------*)
  537.  
  538. VAR
  539.    Local_Save : Saved_Screen_Ptr;
  540.  
  541. BEGIN (* Write_Key_Defs_To_File *)
  542.  
  543.                                    (* Indicate write to file *)
  544.    Save_Screen( Local_Save );
  545.  
  546.    Draw_Menu_Frame( 10, 10, 75, 13, Menu_Frame_Color,
  547.                     Menu_Text_Color, 'Write Function Key Definitions' );
  548.  
  549.                                    (* Get name of file to write to *)
  550.    GoToXY( 2 , 1 );
  551.    WRITE('Enter file name to write definitions to (CR to exit): ');
  552.    ClrEol;
  553.  
  554.    READLN( Input_Key_File_Name );
  555.                                    (* Assume .FNC if type not given *)
  556.  
  557.    IF ( POS( '.', Input_Key_File_Name ) = 0 ) THEN
  558.       Input_Key_File_Name := Input_Key_File_Name + '.FNC';
  559.  
  560.                                    (* Ensure file can be opened *)
  561.  
  562.    IF LENGTH( Input_Key_File_Name ) > 0 THEN
  563.       BEGIN
  564.  
  565.          ASSIGN( Input_Key_File , Input_Key_File_Name );
  566.             (*$I-*)
  567.          REWRITE( Input_Key_File );
  568.             (*$I+*)
  569.  
  570.          IF IoResult <> 0 THEN
  571.             BEGIN (* File bad *)
  572.  
  573.                GoToXY( 2 , 2 );
  574.                WRITE('*** File ',Input_Key_File_Name,' can''t be opened.');
  575.                ClrEol;
  576.  
  577.                DELAY( Two_Second_Delay );
  578.  
  579.             END   (* File bad *)
  580.          ELSE
  581.             BEGIN (* File OK, definitions written *)
  582.  
  583.                                    (* Write out function keys *)
  584.  
  585.                FOR I := 1 TO 4 DO
  586.                   FOR J := 1 TO 10 DO
  587.                      IF LENGTH( Function_Keys[I,J] ) > 0 THEN
  588.                         WRITELN( Input_Key_File, COPY( 'FSCA', I, 1 ),
  589.                                  J:2, '=', Write_Ctrls(Function_Keys[I,J]) );
  590.  
  591.                                    (* Write out keypad keys *)
  592.  
  593.                FOR I := 1 TO 3 DO
  594.                   FOR J := 1 TO 10 DO
  595.                      IF LENGTH( Keypad_Keys[I,J] ) > 0 THEN
  596.                         WRITELN( Input_Key_File,
  597.                                  Keypad_Key_Names[I,J], '=',
  598.                                  Write_Ctrls(Keypad_Keys[I,J]) );
  599.  
  600.                CLOSE( Input_Key_File );
  601.  
  602.                GoToXY( 2 , 2 );
  603.  
  604.                WRITE('Function key definitions written to ',
  605.                       Input_Key_File_Name );
  606.  
  607.                ClrEol;
  608.  
  609.                DELAY( Two_Second_Delay );
  610.  
  611.             END   (* File OK, definitions written *);
  612.  
  613.       END;
  614.                                    (* Restore previous screen          *)
  615.    Restore_Screen( Local_Save );
  616.  
  617. END   (* Write_Key_Defs_To_File *);
  618.  
  619. (*----------------------------------------------------------------------*)
  620.  
  621. BEGIN (* Set_Input_Keys *)
  622.                                    (* If file name specified, get keys *)
  623.                                    (* from specified file.             *)
  624.  
  625.    IF LENGTH( File_Name ) > 0 THEN
  626.       BEGIN
  627.          Read_Key_Defs_From_File;
  628.          EXIT;
  629.       END;
  630.                                    (* Set up menu *)
  631.  
  632.    Input_Key_Menu.Menu_Size    := 4;
  633.    Input_Key_Menu.Menu_Row     := 11;
  634.    Input_Key_Menu.Menu_Column  := 15;
  635.    Input_Key_Menu.Menu_Tcolor  := Menu_Text_Color;
  636.    Input_Key_Menu.Menu_Bcolor  := BackGround_Color;
  637.    Input_Key_Menu.Menu_Fcolor  := Menu_Frame_Color;
  638.    Input_Key_Menu.Menu_Width   := 0;
  639.    Input_Key_Menu.Menu_Height  := 0;
  640.    Input_Key_Menu.Menu_Default := 1;
  641.  
  642.    FOR I := 1 TO 4 DO
  643.       WITH Input_Key_Menu.Menu_Entries[I] DO
  644.       BEGIN
  645.          Menu_Item_Row    := I;
  646.          Menu_Item_Column := 2;
  647.          CASE I Of
  648.             1:  Menu_Item_Text:= 'R)ead definitions from file';
  649.             2:  Menu_Item_Text:= 'E)nter definitions from keyboard';
  650.             3:  Menu_Item_Text:= 'W)rite definitions to file';
  651.             4:  Menu_Item_Text:= 'Q)uit key definition';
  652.          END (* CASE *);
  653.       END;
  654.  
  655.    Input_Key_Menu.Menu_Title := 'Choose Key Definition Method: ';
  656.  
  657.                                    (* Loop until quit chosen *)
  658.    Done := FALSE;
  659.  
  660.    REPEAT
  661.                                    (* Display menu of choices *)
  662.  
  663.       Menu_Display_Choices( Input_Key_Menu );
  664.       Key_Type := Menu_Get_Choice( Input_Key_Menu , Erase_Menu );
  665.  
  666.                                    (* Do requested operation *)
  667.       CASE Key_Type OF
  668.  
  669.          1: Read_Key_Defs_From_File;
  670.          2: Get_Key_Defs_From_Keyboard;
  671.          3: Write_Key_Defs_To_File;
  672.          4: Done := TRUE;
  673.  
  674.       END (* CASE *);
  675.  
  676.    UNTIL Done;
  677.  
  678. END   (* Set_Input_Keys *);